package cn.edu.njupt.post.service;

import cn.edu.njupt.post.dao.MessageDAO;
import cn.edu.njupt.post.model.Message;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageService {
    @Autowired
    MessageDAO messageDAO;


    public int addMessage(Message message) {
        message.setContent(message.getContent());
        return messageDAO.addMessage(message);
    }

    public List<Message> getConversationDetail(String conversationId, int offset, int limit) {
        return messageDAO.getConversationDetail(conversationId, offset, limit);
    }

    public List<Message> getConversationList(int userId, int offset, int limit) {
        return messageDAO.getConversationList(userId, offset, limit);
    }

    public int getConversationUnreadCount(int userId, String conversationId) {
        return messageDAO.getConversationUnreadCount(userId, conversationId);
    }

    public int updateUnread(int userId, String conversationId) {return messageDAO.updateUnread(userId, conversationId);}

    public int getConversationCount(int userId) {return messageDAO.getConversationCount(userId);}

    public int getDetailCount(String conversationId) {return messageDAO.getDetailCount(conversationId);}

    public int deleteById(int id) {return messageDAO.deleteById(id);}
}
